<%@LANGUAGE="VBSCRIPT" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>AdminHelpArticlesDisplay</title>
<link href="UniversalStyleSheet.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
function SaveClick(){
frm=document.getElementById("ArticleForm")
t=document.getElementById("title")
c=document.getElementById("catagory")
p=document.getElementById("parent")
a=document.getElementById("article")
m=document.getElementById("mode")
i=document.getElementById("id")

if (t.value == ""){
	alert("Your Title is blank. Every entry at least needs to have a title.")
	return;
}

tv=t.value
cv=c.options[c.selectedIndex].value
pv=p.options[p.selectedIndex].value
av=a.value
av.replace(String.fromCharCode(13) + String.fromCharCode(10),"|")
mv=m.value
iv=i.value
frm.action="SaveArticle.asp"
frm.submit()
}
</script>

</head>

<body>
<%
mode=request.QueryString("mode")
if mode="edit" then
	set conn=server.CreateObject("adodb.connection")
	set rs=server.CreateObject("adodb.recordset")
	filepath=server.MapPath("access/backend/help.mdb")
	conn.open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FilePath)
	sql="select * from HelpTopics where id=" & request.QueryString("id")
	rs.cursorlocation=3
	rs.open sql,conn,1,2
	rs.activeconnection=nothing
	catagory=rs("catagory")
	title=rs("title")
	parent=rs("parent")
	article=rs("body")
	id=rs("id")
	rs.close
	conn.close
	set rs=nothing
	set conn=nothing
end if
%>
<form action="" method="post" name="ArticleForm" target="SF" id="ArticleForm">

<table width="500" border="0" cellpadding="0" cellspacing="1" bgcolor="#006600">
  <tr>
    <td width="13%" bgcolor="#FFFFFF"><span class="TableTitles">Catagory</span><br />      
      <select name="catagory" size="2" id="catagory">
        <option value="Header" <% if catagory="Header" then response.write ("selected='selected'") %>>Header</option>
        <option value="Article" <% if catagory="Article" then response.write ("selected='selected'") %>>Article</option>
      </select></td>
    <td width="33%" bgcolor="#FFFFFF"><span class="TableTitles">Parent<br />
    </span>
      <select name="parent" id="parent">
        <%
		set conn=server.CreateObject("adodb.connection")
		set rs=server.CreateObject("adodb.recordset")
		filepath=server.MapPath("access/backend/help.mdb")
		sql="select * from HelpTopics where catagory='header'"
		conn.open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FilePath)
		rs.cursorlocation=3
		rs.open sql,conn,1,2
		rs.activeconnection=nothing
		
		do while not rs.eof
			%>
        <option value="<%= rs("id") %>" <% if parent=rs("id") then response.Write("selected='selected'") %>> <%= rs("title") %> </option>
        <%
			rs.movenext
		loop
		rs.close
		conn.close
		set rs=nothing
		set conn=nothing
		%>
      </select>
      <input name="mode" type="hidden" id="mode" value="<%= mode %>"/>
      <input name="id" type="hidden" id="id" value="<%= id %>"/></td>
    <td width="54%" align="right" bgcolor="#FFFFFF">
	<iframe id="SF" name="SF" title="SF" width="1" height="1"></iframe>
	<img src="Images/SaveButton.png" alt="Save" width="60" height="30" onclick="SaveClick()"/></td>
  </tr>
  <tr>
    <td colspan="3" bgcolor="#FFFFFF"><label></label>      
	<label class="TableTitles">Title<br />
        <input name="title" type="text" id="title" value="<%=title %>" size="60"/>
      </label></td>
  </tr>
  
  <tr>
    <td colspan="3" bgcolor="#FFFFFF"><label class="TableTitles">Article<br />
        <textarea name="article" cols="60" rows="28" id="article" ><%= article %>
</textarea>
    </label></td>
  </tr>
</table>
</form>
</body>
</html>
